﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmFamilyService.h"
#include "IFamilyGeneralForm.h"

namespace gfam
{

    class IFamily2DSketchCurve;
    class IFamily2DSketchLine;
    class IFamilySketch;

    ///\brief 放样体错误类型
    enum class SweepPathProfileErrorType
    {
        Valid = 0,                ///<合法

        PathValid = 1,            ///<路径正确
        PathNoSketch = 2,         ///<没有草图平面
        PathEmpty = 3,            ///<路径线为空
        PathIllegal = 4,          ///<路径线不合法

        ProfileValid = 5,         ///<轮廓线正确
        ProfileNoSketch = 6,      ///<没有草图平面
        ProfileEmpty = 7,         ///<轮廓线为空
        ProfileNotClosed = 8,     ///<轮廓线不封闭
        ProfileMultiPolygon = 9,  ///<含多个封闭轮廓
        Intersect = 10,           ///<环相交
        SelfIntersect = 11,       ///<环自交

        PickPathValid = 12,       ///<拾取路径正确
        PickPathNoSketch = 13,    ///<没有草图平面
        PickPathEmpty = 14,       ///<拾取路径为空
        PickPathIllegal = 15,     ///<拾取路径非法

        ProfileFamilyIllegal = 16,///<轮廓族非法
        BothExist = 17            ///<轮廓族与草图线同时存在
    };

    /// \brief 放样体
    class GM_FAMILY_SERVICE_EXPORT IFamilySweep : public IFamilyGeneralForm
    {
        DEFINE_CAST_DERIVED(gfam::IFamilySweep, gfam::IFamilyGeneralForm)

    public:
        /// \brief 创建放样体
        /// 
        /// \param pDocument 文档
        /// \param pathSketchId 路径草图id
        /// \param profileSketchId 轮廓草图id
        /// \param profileLocationCurveIndex  轮廓所在的路径曲线索引
        /// \return 放样体
        static IFamilySweep* Create(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& pathSketchId
            , const gcmp::ElementId& profileSketchId
            , int profileLocationCurveIndex);

        /// \brief 获取路径草图id
        /// 
        /// \return 路径草图id
        virtual gcmp::ElementId GetPathSketchId() const = 0;

        /// \brief 设置路径草图id
        /// 
        /// \param id 草图id
        /// \return 设置成功返回true,否则返回false
        virtual bool SetPathSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取轮廓草图id
        /// 
        /// \return 轮廓草图id
        virtual gcmp::ElementId GetProfileSketchId() const = 0;

        /// \brief 设置轮廓草图id
        /// 
        /// \param id 草图id
        /// \return 设置成功返回true,否则返回false
        virtual bool SetProfileSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取路径草图
        /// 
        /// \return 路径草图
        virtual const IFamilySketch* GetPathSketch() const = 0;

        /// \brief 获取路径草图
        /// 
        /// \return 路径草图
        virtual IFamilySketch* GetPathSketch() = 0;

        /// \brief 获取轮廓草图
        /// 
        /// \return 轮廓草图
        virtual const IFamilySketch2D* GetProfileSketch() const = 0;

        /// \brief 获取轮廓草图
        /// 
        /// \return 轮廓草图
        virtual IFamilySketch2D* GetProfileSketch() = 0;


        /// \brief 获取轮廓所在的路径曲线索引
        /// 
        /// \return 轮廓所在的路径曲线索引
        virtual int GetProfileLocationCurveIndex() const = 0;

        /// \brief 设置轮廓所在的路径曲线索引
        /// 
        /// \param profileLocationCurveIndex 轮廓所在的路径曲线索引
        /// \return 设置成功返回true,否则返回false
        virtual bool SetProfileLocationCurveIndex(int profileLocationCurveIndex) = 0;

        /// \brief 获取是否正在编辑放样体
        /// 
        /// \return 正在编辑放样体返回true,否则返回false
        virtual bool GetIsEditingSweep() const = 0;

        /// \brief 设置是否正在编辑放样体
        /// 
        /// \param bIsEditingSweep 是否正在编辑放样体
        virtual void SetIsEditingSweep(bool bIsEditingSweep) = 0;

        /// \brief 计算放样轮廓的草图平面坐标系
        /// 
        /// \param coordProfilePlane 保存计算出来的坐标系
        /// \return 操作成功返回true,否则返回false
        virtual bool ComputeProfilePlane(gcmp::Coordinate3d& coordProfilePlane) const = 0;  

        /// \brief 检查轮廓是否合法
        /// 
        /// \param errorCurves 出错的草图线
        /// \return 放样体错误类型
        virtual SweepPathProfileErrorType CheckProfileIsValid(std::vector<IFamilySketchCurve*>& errorCurves) const = 0;

        /// \brief 检查二维路径是否合法
        /// 
        /// \return 放样体错误类型
        virtual SweepPathProfileErrorType CheckSweepPath2d() const = 0;

        /// \brief 设置轮廓族实例id
        /// 
        /// \param id  轮廓族实例id
        /// \return 设置成功返回true,否则返回false
        virtual bool SetInstanceIdOfProfileFamily(const gcmp::ElementId& id) = 0;

        /// \brief 获取轮廓族实例id
        /// 
        /// \return 轮廓族实例id
        virtual gcmp::ElementId GetInstanceIdOfProfileFamily() const = 0;

        /// \brief 获取轮廓族实例
        /// 
        /// \return 轮廓族实例
        virtual gcmp::IElement*  GetProfileFamilyInstance() = 0;

        /// \brief 获取轮廓族实例
        /// 
        /// \return 轮廓族实例
        virtual const gcmp::IElement* GetProfileFamilyInstance()const = 0;
    };

}
